import Vue from 'vue';
import NoticeBox from './NoticeBox';

NoticeBox.newInstance = () => {
  const el = document.createElement('div');
  el.innerHtml = '<notice-box></notice-box>';
  document.body.appendChild(el);
  const noticeBox = new Vue({
    el,
    components: {
      NoticeBox,
    },
  }).$children[0];
  
  return {
    component: noticeBox,
    add(notice) {
      noticeBox.add(notice);
    },
    remove(key) {
      noticeBox.remove(key);
    },
    destroy() {
      document.body.removeChild(el);
    },
  };
};

export default NoticeBox;
